package com.course.action;

import java.io.IOException;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.Vector;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;

import com.course.bean.ExamTo;
import com.course.delegate.ExamMgrDelegate;
import com.course.exception.DataNotFoundException;
import com.course.util.UtilConstants;



public class ViewQusetionPaperAction extends HttpServlet {

	
	private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
                   doPost(request, response);
                   }
public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		
        String path="";
        Vector<ExamTo>  viewquestion=null;

	  try{
		  try{
		  viewquestion= new ExamMgrDelegate().viewQuestion();
		  }catch (DataNotFoundException e) {
			e.printStackTrace();}
		   System.out.println("in Action class vcb..........."+viewquestion);
		  if(!viewquestion.isEmpty()){
			  request.setAttribute("Questionpaper", viewquestion);
			  request.setAttribute("status", UtilConstants._QUESTION_INFO);
			  path=UtilConstants._STUDENT_EXAM_HOME;
			 }
		  else {
			  request.setAttribute("status", UtilConstants._NO_QUESTION_INFO);
			  path=UtilConstants._STUDENT_EXAM_HOME;
			}
		 }
	  catch (NullPointerException e) {
		  request.setAttribute("status", UtilConstants._INVALIED_DATA);
		  path=UtilConstants._STUDENT_EXAM_HOME;
		e.printStackTrace();
		path="StudentExam.jsp?status=Invalid Entries";
	}
RequestDispatcher rd=request.getRequestDispatcher(path);
		rd.forward(request,response);
	}

}
